home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 46 / Amiga Format CD46 (1999-10-20)(Future Publishing)(GB)[!][issue 1999-12].iso / -serious- / programming / other / tandem / teaching / 67.asm < prev    next >
Assembly Source File  |  1999-09-06  |  4KB  |  138 lines

  1. * 67.asm     TLbutmon        0.00        8.6.99)
  2.  
  3.  
  4.  include 'Front.i'
  5.  
  6.  
  7. ;box size & contents data
  8. xwid: ds.l 1                ;width of 2nd box set
  9. radi: ds.l 1                ;which button of 1st box set selected
  10. prev: ds.w 1                ;previous box clicked (ASCII of set,box)
  11.  
  12.  
  13. strings: dc.b 0
  14. st_1: dc.b  'TLbutmon demonstration',0 ;1
  15.  dc.b 'Error: out of chip ram',0 ;2
  16.  dc.b 'A box\Another\Yet another\Yes! Another\The Last non-blank box',0 ;3
  17.  dc.b 'Click me!',0 ;4
  18.  dc.b 'No - click me!',0 ;5
  19.  dc.b 'Or, click me',0 ;6
  20.  dc.b 'Click any box from either set of buttons',0 ;7
  21.  dc.b '(Click the close window gadget to quit)',0 ;8
  22.  dc.b 'Set 1 - radio buttons',0 ;9
  23.  dc.b 'Set 2 - some boxes with text',0 ;10
  24.  dc.b 'Your last click was set '
  25. st_11a: dc.b ' , box '
  26. st_11b: dc.b ' ',0 ;11
  27.  
  28.  ds.w 0
  29.  
  30.  
  31. Program:
  32.  TLwindow #-1
  33.  beq Pr_bad
  34.  TLwindow #0,#0,#0,#200,#100,xxp_Width(a4),xxp_Height(a4),#0,#st_1
  35.  beq Pr_bad
  36.  
  37.  clr.w prev                ;no input yet
  38.  
  39. Pr_draw:                   ;draw the window contents
  40.  TLreqcls                  ;clear window, update window size
  41.  
  42.  move.l xxp_AcWind(a4),a5  ;print instructions
  43.  move.w #$0200,xxp_FrontPen(a5)
  44.  TLstring #7,#10,#5
  45.  TLstring #8,#10,#13
  46.  subq.b #1,xxp_FrontPen(a5)
  47.  
  48.  TLstring #9,#10,#43       ;print 1st set
  49.  TLstring #4,#30,#54
  50.  TLstring #5,#30,#69
  51.  TLstring #5,#30,#84
  52.  move.l #10,xxp_butx(a4)   ;posn = 10,53
  53.  move.l #53,xxp_buty(a4)
  54.  move.l #12,xxp_butw(a4)   ;size = 12 X 10
  55.  move.l #10,xxp_buth(a4)
  56.  move.l #15,xxp_btdy(a4)   ;dy = 15   (no dx since butk=1)
  57.  move.l #1,xxp_butk(a4)    ;columns = 1
  58.  move.l #3,xxp_butl(a4)    ;rows = 3
  59.  TLbutprt                  ;print buttons
  60.  
  61.  TLstring #10,#10,#106     ;print 2nd set
  62.  move.l #116,xxp_buty(a4)
  63.  TLstra0 #3                ;point to button contents
  64.  TLbutstr a0               ;set butx,buty for them
  65.  move.l xxp_butw(a4),xwid  ;cache button width
  66.  move.l xxp_butw(a4),xxp_btdx(a4) ;buttons touch horz & vert
  67.  move.l xxp_buth(a4),xxp_btdy(a4)
  68.  move.l #3,xxp_butk(a4)    ;columns = 3
  69.  move.l #2,xxp_butl(a4)    ;rows = 2
  70.  TLbuttxt a0               ;print text in them
  71.  TLbutprt                  ;print buttons
  72.  
  73. Pr_chek:
  74.  move.l radi,d2            ;print checkmark
  75.  mulu #15,d2
  76.  add.w #54,d2              ;ypos = radi * btdy + 54
  77.  TLpict #10,#12,d2         ;pict 10 at 12,d2
  78.  
  79. Pr_prev:
  80.  tst.w prev                ;go if not input yet
  81.  beq.s Pr_wait
  82.  move.b prev,st_11a        ;else, show last input
  83.  move.b prev+1,st_11b
  84.  TLstring #11,#10,#150
  85.  
  86. Pr_wait:                   ; wait for user response
  87.  TLwcheck
  88.  bne Pr_draw               ;redraw if window resized
  89.  TLkeyboard                ;get input
  90.  cmp.b #$93,d0
  91.  beq Pr_quit               ;quit if close window
  92.  cmp.b #$80,d0
  93.  bne Pr_wait               ;else reject unless lmb
  94.  
  95.  move.l #10,xxp_butx(a4)   ;set up to monitor 1st button set
  96.  move.l #53,xxp_buty(a4)
  97.  move.l #12,xxp_butw(a4)
  98.  move.l #10,xxp_buth(a4)
  99.  move.l #15,xxp_btdy(a4)
  100.  move.l #1,xxp_butk(a4)
  101.  move.l #3,xxp_butl(a4)
  102.  
  103.  TLbutmon d1,d2            ;was 1st set clicked?
  104.  beq.s Pr_set2             ;no, to second set
  105.  move.b #'1',prev
  106.  move.b #'0',prev+1        ;record lst keyboard input
  107.  add.b d0,prev+1
  108.  
  109.  move.l radi,d1            ;d1 = old checkmark
  110.  subq.l #1,d0              ;d0 = new chweckmark, 0-2
  111.  move.l d0,radi            ;which save in radi
  112.  mulu #15,d1
  113.  add.w #54,d1
  114.  TLreqarea #12,d1,#8,#8,#0 ;clear old checkmark
  115.  bra Pr_chek               ;print new checkmark, to next input
  116.  
  117. Pr_set2:                   ;set up to monitor 2nd button set
  118.  move.l #116,xxp_buty(a4)
  119.  move.l xwid,xxp_butw(a4)
  120.  move.l xxp_butw(a4),xxp_btdx(a4)
  121.  move.l #10,xxp_buth(a4)
  122.  move.l #10,xxp_btdy(a4)
  123.  move.l #3,xxp_butk(a4)
  124.  move.l #2,xxp_butl(a4)
  125.  
  126.  TLbutmon d1,d2            ;monitor 2nd button set
  127.  beq Pr_wait               ;go if neither set
  128.  move.b #'2',prev          ;else record which clicked
  129.  move.b #'0',prev+1
  130.  add.b d0,prev+1
  131.  bra Pr_prev               ;& await next input
  132.  
  133. Pr_bad:                    ;report out of mem if bad
  134.  TLbad #2
  135.  
  136. Pr_quit:                   ;exit from Program
  137.  rts
  138.